package ${package}.${packageController};

<#assign upClassName=className?cap_first>
import ${package}.${packageEntity}.${upClassName};
import ${package}.${packageService}.I${upClassName}Service;
import com.syswin.systoon.framework.bean.ResponseResult;
import com.syswin.systoon.framework.constant.CoreConstants;
import com.syswin.systoon.framework.exception.BusinessException;
import ${package}.constant.ConfCoreConstants;
import ${package}.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "${tableComment}")
@RestController
@RequestMapping(ConfCoreConstants.RestPathPrefix.FORM + "/${className}")
public class ${upClassName}${classNameControllerSuffix} extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(${upClassName}${classNameControllerSuffix}.class);

    @Autowired
    private I${upClassName}Service ${className}Service;

    @ApiOperation(value = "创建${tableComment}", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ResponseResult create(@ApiParam(value = "${tableComment}", required = true) @RequestBody ${upClassName} paramBean) {
        ${className}Service.create(paramBean);
        return ResponseResult.success(null);
    }

    @ApiOperation(value = "查询${tableComment}", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "findList", method = RequestMethod.POST)
    public ResponseResult<List<${upClassName}>> findList(@ApiParam(value = "${tableComment}", required = true) @RequestBody ${upClassName} paramBean) {
        return ResponseResult.success(${className}Service.findList(paramBean));
    }

    @ApiOperation(value = "修改${tableComment}", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "/modifyById", method = RequestMethod.POST)
    public ResponseResult modifyById(@ApiParam(value = "${tableComment}", required = true) @RequestBody ${upClassName} paramBean) {
        ${className}Service.modifyById(paramBean);
        return ResponseResult.success(null);
    }

    @ApiOperation(value = "根据主键删除${tableComment}", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "deleteById", method = RequestMethod.POST)
    public ResponseResult deleteById(@ApiParam(value = "${tableComment}id", required = true) @RequestParam Long id) {
        if(null == id) {
            throw new BusinessException(CoreConstants.REQUEST_ERROR_PARAMS, "输入参数异常，id值为空!", false);
        }
        ${className}Service.deleteById(id);
        return ResponseResult.success(null);
    }

    @ApiOperation(value = "根据主键获取${tableComment}", notes = "<p style='font-weight:normal;font-size:15px'>" +
        "</br>返回码： " +
        "</br>code：0，message ：操作成功；代表请求成功，如果有返回数据则在data中 " +
        "</br>code：-1，message ：（错误信息）；代表请求参数不合法" +
        "</br>code：-100，message ：（错误信息）；代表内部系统错误！</p>")
    @RequestMapping(value = "get${upClassName}ById", method = RequestMethod.POST)
    public ResponseResult<${upClassName}> get${upClassName}ById(@ApiParam(value = "${tableComment}id", required = true) @RequestParam Long id) {
        ${upClassName} result = null;
        if(null == id) {
            return ResponseResult.success(result);
        }
        result = ${className}Service.get${upClassName}ById(id);
        return ResponseResult.success(result);
    }

}